public class Wife {
    private String name;
    private Family family;
    public Wife(String name) {
        this.name = name;
    }
    public void setFamily(Family family) {
        this.family = family;
    }
    public void shopping(double money) {
        synchronized (this.family) {
            double leftMoney = this.family.getAccount();
            System.out.println("wife 消费前，家庭余额："+ leftMoney);
            if(leftMoney >= money){
                this.family.setAccount(leftMoney-money);
                System.out.println("wife消费后，家庭余额：" + this.family.getAccount());
            }else{
                System.out.println("账户余额不足，wife暂停消费+++++++");
            }
        }
    }
}
